/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1552018861843_7238';

  // add your middleware config here
  config.middleware = ['auth'];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };


  config.mysql = {
    clients: {

      uat_weshop: {
        // host
        host: '221.180.255.229',
        // 端口号
        port: '37406',
        // 用户名
        user: 'royzhang012',
        // 密码
        password: 'royzhang012',
        // 数据库名
        database: 'uat_weshop',
      },

      sys: {
        // host
        host: '221.180.255.229',
        // 端口号
        port: '37406',
        // 用户名
        user: 'royzhang012',
        // 密码
        password: 'royzhang012',
        // 数据库名
        database: 'uat_weshop',
      },


      uat_community: {
        // host
        host: '221.180.255.229',
        // 端口号
        port: '37406',
        // 用户名
        user: 'royzhang012',
        // 密码
        password: 'royzhang012',
        // 数据库名
        database: 'uat_community',
      },

    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  config.redis = {

    clients: {

      system: {
        port: 36379, // Redis port
        host: '47.105.46.65', // Redis host
        password: '2015@Juyou',
        db: 8,
      },

      member: {
        port: 36379,
        host: '47.105.46.65',
        password: '2015@Juyou',
        db: 8,
      },

      tmp: {
        port: 36379,
        host: '47.105.46.65',
        password: '2015@Juyou',
        db: 8,
      },
      //存用户信息的
      user: {
        port: 36379,
        host: '47.105.46.65',
        password: '2015@Juyou',
        db: 7,
      },
    },

  };


  config.cluster = {
    listen: {
      port: 39999,
      // hostname: '127.0.0.1',
      // path: '/var/run/egg.sock',
    },
  };

  config.security = {
    csrf: false,
  };

  config.bodyParser = {
    jsonLimit: '1mb',
    formLimit: '1mb',
  };

  config.auth = {
    match : '/v1',
  };

  config.csrf = {
    enable : false,
  };

  config.onerror = {
    all(err, ctx) {

      console.log('onerror all');

      console.log(err);
      console.log(ctx);

       ctx.body = {
        errmsg : 'rpc error',
        errcode : 10001,
      };
      ctx.status = 201;
    },
  }


  return {
    ...config,
    ...userConfig,
  };
};
